﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fortuitus.Core
{
    public static class Statistics
    {
        /// <summary>
        /// Calculates the fold change of two number greater than zero.
        /// </summary>
        /// <param name="a">The first number.</param>
        /// <param name="b">The second number.</param>
        /// <returns>The fold change that gives the number of time b is greater than a.</returns>
        /// <exception cref="ArgumentException">Both numbers need to be greater than zero.</exception>
        public static double FoldChange(double a, double b)
        {
            if (a <= 0 || b <= 0)
                throw new ArgumentException("Foldchange is only defined for number greater than zero");

            double foldchange;
            double ratio = b / a;
            if (ratio < 1)
                foldchange = 1 / ratio;
            else
                foldchange = ratio;

            return foldchange;

        }
    }
}
